﻿Imports System.Text
Imports System.Net
Imports System.IO
Imports System.Security.Cryptography
Imports System.Web
Imports System.Xml
Imports System.Security
Imports System.Runtime
Imports System.Runtime.InteropServices
Imports System.Collections.Specialized

Public Class TwitterOAuth
    Inherits Net.Twitter.OAuthBase
    Public Sub New(ByVal consumerKey As String, ByVal consumerSecret As String)
        MyBase.New(consumerKey, consumerSecret)
    End Sub
    Public Sub New(ByVal consumerKey As String, ByVal consumerSecret As String, ByVal Token As String, ByVal TokenSecret As String)
        MyBase.New(consumerKey, consumerSecret)
        Me._token = Token
        Me._tokenSecret = TokenSecret
    End Sub
    Public Sub AddToken(ByVal token As String, ByVal tokenSecret As String)
        Me._token = token
        Me._tokenSecret = tokenSecret
    End Sub
    Public Function Update(ByVal Status As String) As Boolean
        Try
            Dim r = Me.Post(If(String.IsNullOrEmpty(My.Settings.ApiUrl), Endpoint, My.Settings.ApiUrl) + "1/statuses/update.xml", New With {.status = Status})
            If String.IsNullOrEmpty(r) Then
                Return False
            Else
                Return True
            End If
        Catch
            Return False
        End Try
    End Function

    Public Function VerifyCredentials() As Boolean
        Try
            Dim r = Me.Get(If(String.IsNullOrEmpty(My.Settings.ApiUrl), Endpoint, My.Settings.ApiUrl) + "1/account/verify_credentials.xml", Nothing)
            If String.IsNullOrEmpty(r) Then
                Return False
            Else
                Return True
            End If
        Catch
            Return False
        End Try
    End Function
End Class